
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>

int main(int argc, const char *argv[])
{
    int fd;
    int buf;
    int count;
    int i = 0;

    printf("------------------start \n");

    fd = open("/dev/led_dev", O_RDWR);
    if (fd < 0) {
        printf("open faild \n");
        return -1;
    }

    while (i++ < 4) {
        buf = 1;
        count = write(fd, &buf, sizeof(int));
        printf("count: %d, err: %s \n", count, strerror(errno));
        sleep(5);

        buf = 0;
        count = write(fd, &buf, sizeof(int));
        printf("count: %d, err: %s \n", count, strerror(errno));
        sleep(5);
    }

    close(fd);

    printf("------------------end \n");

    return 0;
}
